<?php

require_once dirname(__FILE__) . '/../lib/schoolGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/schoolGeneratorHelper.class.php';

/**
 * school actions.
 *
 * @package    sf_sandbox
 * @subpackage school
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class schoolActions extends autoSchoolActions {

    public function executeExport(sfWebRequest $request) {
        $q = parent::buildQuery();

        $q->select('
            intg_id
            , sector.name as sector
            , name
            , phone
            '
        );

        $q->leftJoin('r.CodeSector as sector');

        $items = $q->fetchArray();

        $order = array(
            'intg_id'
            , 'sector'
            , 'name'
            , 'phone'
        );

        $labels = array(
            'intg_id' => 'Number'
            , 'sector' => 'Sector'
            , 'name' => 'Name'
            , 'phone' => 'Phone'
        );

        $partial = $this->getPartial('teacher/export', array('items' => $items, 'order' => $order, 'labels' => $labels));

        $word = globals::wordify($partial);

        header('Content-type: application/doc');
        header('Content-Disposition: attachment; filename="schools_list_' . (substr(time(), 0, 5)) . '.doc"');
        header('Content-Description: File Transfer');

        die($word);
    }

}
